package org.thanos.demo.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.thanos.demo.constant.Topic;

import java.util.Optional;

@Component
public class DemoKafkaConsumer {

    @KafkaListener(topics = Topic.DEMO)
    public void consume(ConsumerRecord consumerRecord) {
        Optional<Object> kafkaMassage = Optional.ofNullable(consumerRecord.value());
        if (kafkaMassage.isPresent()) {
            Object o = kafkaMassage.get();
            System.out.println(o);
        }
    }
}
